package com.niji.littly_donkey_android.ui;

import android.os.Bundle;


import android.view.View;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.niji.littly_donkey_android.R;
import com.niji.littly_donkey_android.adapter.MessageCenterAdapter;
import com.niji.littly_donkey_android.bean.Message;
import com.niji.littly_donkey_android.util.TimeUtil;
import com.niji.littly_donkey_android.view.MessageCenterView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
 * SlideRecyclerView测试
 * <p>
 *
 */

public class SlideRecyclerViewActivity extends AppCompatActivity {

    private MessageCenterView recycler_view_list;
    private List<Message> mInventories;
    private MessageCenterAdapter mMessageCenterAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.message_centor_activity);
        recycler_view_list = (MessageCenterView) findViewById(R.id.message_center_list);
        recycler_view_list.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        DividerItemDecoration itemDecoration = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
        itemDecoration.setDrawable(ContextCompat.getDrawable(this, R.drawable.divider_inset));
        recycler_view_list.addItemDecoration(itemDecoration);
        mInventories = new ArrayList<>();
        Message inventory;
        Random random = new Random();

        mMessageCenterAdapter = new MessageCenterAdapter(this, mInventories);
        recycler_view_list.setAdapter(mMessageCenterAdapter);
        mMessageCenterAdapter.setOnDeleteClickListener(new MessageCenterAdapter.OnDeleteClickLister() {
            @Override
            public void onDeleteClick(View view, int position) {
                mInventories.remove(position);
                mMessageCenterAdapter.notifyDataSetChanged();
                recycler_view_list.closeMenu();
            }
        });
    }
}
